package com.link2room.soundwave.controller.inside;


import com.link2room.common.dto.result.base.BaseResultDto;
import com.link2room.jetfire.dto.param.base.ReservationParamDto;
import com.link2room.soundwave.dto.param.base.PmsReservationBaseParamDto;
import com.link2room.soundwave.dto.param.inside.BookInfoListInsideParamDto;
import com.link2room.soundwave.dto.param.inside.MemeberCardPayInsideParamDto;
import com.link2room.soundwave.dto.param.inside.PmsReservationPayInsideParamDto;
import com.link2room.soundwave.util.HandlerUtil;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * Created by VegetaKo on 2016/9/14.
 */
@Api(tags = "PMS订单相关")
@RestController
@RequestMapping("/in/PMSReservations")
public class PMSReservationInsideController {

    @RequestMapping(method = RequestMethod.POST)
    public BaseResultDto savePmsReservation(
            @RequestBody ReservationParamDto reservationParamDto) throws Exception {
        HandlerUtil.pmsReservationHandler().savePMSReservationHandler(reservationParamDto);
        BaseResultDto l2rRs = new BaseResultDto();
        l2rRs.setResultCode(0);
        return l2rRs;
    }

    @RequestMapping(value = "/Payment", method = RequestMethod.POST)
    public BaseResultDto saveReservationPay(
            @RequestBody PmsReservationPayInsideParamDto pmsReservationPayInsideParamDto
    ) throws Exception {
        BaseResultDto l2rRs = new BaseResultDto();
        l2rRs.setResultCode(0);
        HandlerUtil.pmsReservationHandler().savePMSReservationPayHandler(pmsReservationPayInsideParamDto);
        return l2rRs;
    }

    @RequestMapping(method = RequestMethod.GET)
    public BaseResultDto getPMSReservations(
            @RequestParam(value = "l2rNos", required = false) String l2rNos
    ) throws Exception {
        BookInfoListInsideParamDto bookInfoListInsideParamDto = new BookInfoListInsideParamDto();
        BaseResultDto l2rRs = new BaseResultDto();
        bookInfoListInsideParamDto.setL2rNos(l2rNos );
        l2rRs.setResultCode(0);
        l2rRs.setQueryResult(HandlerUtil.pmsReservationHandler().getPMSReservationsHandler(bookInfoListInsideParamDto));
        return l2rRs;
    }

    @RequestMapping(value = "/PMSReservationsNights", method = RequestMethod.GET)
    public BaseResultDto getPMSReservationsNights(
            @RequestParam(value = "l2rNo", required = false) String l2rNo
    ) throws Exception {
        //BookInfoListInsideParamDto bookInfoListInsideParamDto = new BookInfoListInsideParamDto();
        BaseResultDto l2rRs = new BaseResultDto();
        //bookInfoListInsideParamDto.setL2rNos(l2rNos );
        l2rRs.setResultCode(0);
        //l2rRs.setQueryResult(pmsReservationFacadeService.getPMSReservations(bookInfoListInsideParamDto));
        return l2rRs;
    }

    @RequestMapping(value = "/Accounts", method = RequestMethod.GET)
    public BaseResultDto getPMSReservationsAccounts(
            @RequestParam(value = "lhotelCode", required = false) String lhotelCode,
            @RequestParam(value = "crsNo", required = false) String crsNo,
            @RequestParam(value = "l2rNo", required = false) String l2RNo
    ) throws Exception {
        PmsReservationBaseParamDto pmsReservationBaseParamDto = new PmsReservationBaseParamDto();
        pmsReservationBaseParamDto.setLhotelCode(lhotelCode);
        pmsReservationBaseParamDto.setCrsNo(crsNo);
        pmsReservationBaseParamDto.setL2rNo(l2RNo);
        BaseResultDto l2rRs = new BaseResultDto();
        //bookInfoListInsideParamDto.setL2rNos(l2rNos );
        l2rRs.setResultCode(0);
        l2rRs.setQueryResult(HandlerUtil.pmsReservationHandler().listPmsAccountsHandler(pmsReservationBaseParamDto));
        return l2rRs;
    }

    @RequestMapping(value = "/Accounts/Count", method = RequestMethod.GET)
    public BaseResultDto getPMSReservationsAccounts(
            @RequestParam(value = "ids", required = false) List<Long> ids
    ) throws Exception {
        PmsReservationBaseParamDto pmsReservationBaseParamDto=new PmsReservationBaseParamDto();
        pmsReservationBaseParamDto.setIds(ids);
        BaseResultDto l2rRs = new BaseResultDto();
        l2rRs.setResultCode(0);
        l2rRs.setResultInfo(HandlerUtil.pmsReservationHandler().getAccountResultHandler(pmsReservationBaseParamDto));
        return l2rRs;
    }

    @RequestMapping(value = "/MemberCardPrepay", method = RequestMethod.POST)
    public BaseResultDto<String> memberCardPrepay(
            @RequestBody MemeberCardPayInsideParamDto memeberCardPayInsideParamDto
    ) throws Exception {
        BaseResultDto baseResultDto = new BaseResultDto();
        baseResultDto.setResultCode(0);
        baseResultDto.setResultInfo(HandlerUtil.pmsReservationHandler().memberCardPrepayHandler(memeberCardPayInsideParamDto));
        return baseResultDto;
    }
}
